package com.yaowk.system.Interceptor;

import com.jfinal.aop.Invocation;

/**
 * 通过方法名记录日志
 *
 * @authc yaowk
 * 2017/4/25
 */
public class LogByMethod extends LogInterceptor {

    private String[] methods = new String[] { "add", "edit", "remove" };

    @Override
    public void intercept(Invocation inv) {

        String method = inv.getMethodName();
        boolean flag = false;
        // 判断这个方法是否拦截
        for (String m : methods) {
            if (method.startsWith(m)) {
                flag = true;
                break;
            }
        }
        if (flag) {
            log(inv);
        }
        inv.invoke();
    }

}
